#ifndef __GLWINDOW_H_INCLUDED__
#define __GLWINDOW_H_INCLUDED__

#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN

#include <windows.h>
#include "IBaseApp.h"

#include<gl/gl.h>
#include<gl/glu.h>

#include "wgl/wglext.h"

struct GLWindowParams
{
	GLWindowParams() : 
		windowWidth(1280),
		windowHeight(720),
		windowBPP(32),
		windowFullscreen(false) {}

	unsigned int windowWidth;
	unsigned int windowHeight;
	unsigned int windowBPP;
	bool windowFullscreen;
};

class GLWindow
{
public:

	GLWindow(HINSTANCE i_hInstance);
	~GLWindow(void);

	void attachApp(IBaseApp* i_pBaseApp);
	bool create( const GLWindowParams& i_oWindowParams = GLWindowParams() );
	void destroy();
	bool isRunning();
	void processEvents();
	float getElapsedSeconds();
	void update(float i_fDeltaTime);
	void render();
	void swapBuffers();

	static GLuint getSystemFont() { return s_nFontList; }

private:

	static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	void setupPixelFormat(void);

	void createSystemFont();
	static GLuint s_nFontList;

	HINSTANCE	m_hInstance;
	IBaseApp*	m_pBaseApp;
	bool		m_isFullscreen;
	bool		m_bIsRunning;
	RECT		m_windowRect;
	WNDCLASSEX	m_windowClass;
	HWND		m_hWnd;
	HDC			m_hDC;
	HGLRC		m_hglrc;
	float		m_lastTime;
};

#endif // __GLWINDOW_H_INCLUDED__